const Koa = require('koa');
const app = new Koa();

app.use(async (ctx, next) => {
    console.log(1);
    try {
        await next();
    } catch (error) {
        console.log(error);
    }
    
    console.log(4);
    
});
app.use(async (ctx, next) => {
    console.log(2);
    await next();
    console.log(5);
});
app.use(async (ctx, next) => {
    console.log(3);
    aaa
    await next();
    console.log(6);
});

app.on('error', (err, ctx) => {
    console.error('server error', err, ctx)
});

app.listen(3000, () => {
    console.log(' koa server start!');
});
